﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace XHCTMS.Util
{
    public class UserInfo
    {
        public string UserID { get; set; }
        public string UserName { get; set; }
        public string UserJob { get; set; }
        public string UserDep { get; set; }
        public string UserTitle { get; set; }
    }


    public class SetUserSession
    {
        public static UserInfo userSession
        {
            set
            {
                HttpContext.Current.Session["UserInfo"] = value;
            }
            get
            {
                if (HttpContext.Current.Session["UserInfo"] != null)
                {
                    return HttpContext.Current.Session["UserInfo"] as UserInfo;
                }
                else
                {
                    return null;
                }
            }
        }
    }

    public class SetUserCookie
    {
        public static string userCookie
        {
            set
            {
                HttpContext.Current.Response.Cookies["UserInfo"].Value = value;
                HttpContext.Current.Response.Cookies["UserInfo"].Expires = DateTime.Now.AddHours(3);
            }
            get
            {
                try
                {
                    return HttpContext.Current.Response.Cookies["UserInfo"].Value;
                }
                catch
                {
                    return string.Empty;
                }
            }
        }
    }

}
